package com.xmy.cultivate.controller;

import com.xmy.cultivate.entity.Quarter;
import com.xmy.cultivate.service.ICourseSchedulingAlwaysService;
import com.xmy.cultivate.service.IQuarterService;
import com.xmy.cultivate.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 日期总排课表，计算缺课使用(校历) 前端控制器
 * </p>
 *
 * @author hpiggy
 * @since 2024-10-16
 */
@RestController
@RequestMapping("/api/courseSchedulingAlways")
public class CourseSchedulingAlwaysController {

    @Autowired
    ICourseSchedulingAlwaysService iCourseSchedulingAlwaysService;

    @Autowired
    IQuarterService iQuarterService;

    @GetMapping("/getLessonNumList")
    public Result getLessonNumList(@RequestParam("yearPart") Integer yearPart,
                                   @RequestParam("quarterNum") Integer quarterNum){
        if (yearPart ==null){
            Quarter quarterNow = iQuarterService.getNowQuarter();
            yearPart = quarterNow.getYearPart();
            quarterNum = quarterNow.getNum();
        }

        Result rs = iCourseSchedulingAlwaysService.getLessonNumList(yearPart,quarterNum);
        return rs;
    }
}
